static bool setwinclose( wchar_t *name, long mt ){
cell c;
c.hWnd = NULL;
char name1[ 256 ];
HWND hWnd;
long st = GetTickCount( );
long ct = 100;
long ct1 = 0;
long et = st + ct;
long mt1 = 300;
long dmy = 0;
char* dmy1 = wchartochar( name, wcslen( name ) );
strcpy( name1, dmy1 );
strcpy( c.WindowName, name1 );
if ( dbgflg ) printf( "setwinclose function tite [ %ls ]\n", name );
if ( dbgflg ) printf( "setwinclose function tite 1 [ %s ]\n", name1 );
if ( mt > mt1 ) mt = mt1;
if ( dbgflg ) printf( "counter max [ %d ] start time [ %d ] endtime [ %d ]\n", mt, st, et );
do {
st = GetTickCount( );
if ( st >= et ) {
et = st + ct;
ct1 = ct1 + 1;
if ( ct1 >= mt ) break;
EnumWindows( EnumWndProc, ( LPARAM )&c );
if( c.hWnd != NULL ) {
if ( dbgflg ) printf( "get window name [ %s ]\n", c.WindowName );
if ( dbgflg ) printf( "get window handle [ %d ]\n", c.hWnd );
if ( dbgflg ) printf( "windows close message postting\n" );
if ( PostMessage( c.hWnd, WM_CLOSE, dmy, dmy ) ) return true;
if ( dbgflg ) printf( "windows quit message postting\n" );
if ( PostMessage( c.hWnd, WM_QUIT, dmy, dmy ) ) return true;
if ( dbgflg ) printf( "windows destroy message postting\n" );
if ( PostMessage( c.hWnd, WM_DESTROY, dmy, dmy ) ) return true;
if ( dbgflg ) printf( "windows message postting all error\n" );
return false;
}
}
} while ( ct1 >= 0 && ct1 <= mt );
return false;
}